package cn.zhqr.common.util.collections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * Created by yantingjun on 2018/12/18.
 */
public class Lists {
    /**
     * 快速构建ArrayList,并赋初始值
     * @param arrs
     * @return
     */
    public static List arrayList(Object... arrs){
        List list = new ArrayList<>();
        if(arrs!=null){
            Collections.addAll(list, arrs);
        }
        return list;
    }

    /**
     * 集合相减
     * @param l1
     * @param l2
     * @return
     */
    public static List sub(Collection l1, Collection l2) {
        List<Integer> ids = new ArrayList<>();
        ids.addAll(l1);
        ids.removeAll(l2);
        return ids;
    }

    /**
     * 合并多个List
     * @param lists
     * @return
     */
    public static List merge(List... lists){
        List list = new ArrayList();
        for(List l : lists){
            list.addAll(l);
        }
        return list;
    }
}
